package com.zzyl.service.impl;


import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceImpl implements NursingLevelService {


    @Autowired
    private NursingLevelMapper nursingLevelMapper;
    @Override
    public List<NursingLevelVo> getAllNursingLevels() {

        List<NursingLevelVo> nursingLevels = nursingLevelMapper.getAllNursingLevel();
        return nursingLevels;
    }

    @Override
    public NursingLevelVo selectById(Long id) {
        NursingLevel nursingLevel = nursingLevelMapper.selectById(id);
        return BeanUtil.copyProperties(nursingLevel, NursingLevelVo.class);
    }

    @Override
    public PageResponse<NursingLevelVo> selectByPage(Integer pageNum, Integer pageSize, String name, Integer status) {
        PageHelper.startPage(pageNum, pageSize);
        Page<NursingLevelVo> nl = (Page<NursingLevelVo>) nursingLevelMapper.selectByPage(name, status);
        return PageResponse.of(nl, NursingLevelVo.class);
    }

    @Override
    public void deleteNursingLevel(Long id) {
        nursingLevelMapper.deleteNursingLevel(id);

    }

    @Override
    public void updateStatus(Long id, Integer status) {
        nursingLevelMapper.updateStatus(id, status);

    }

    @Override
    public void addNursingLevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel =BeanUtil.copyProperties(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.insert(nursingLevel);



    }

    @Override
    public void updateNursingLevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel = BeanUtil.copyProperties(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.update(nursingLevel);


    }
}
